package ModelLayer;
import java.util.ArrayList;

/**
 * Write a description of class managerContainer here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class ManagerContainer
{
    private ArrayList<Manager> managerContainer;
    private static ManagerContainer instance;
    public ManagerContainer()
    {
        managerContainer = new ArrayList<Manager>();
    }

    public static ManagerContainer getInstance()
    {
        if(instance == null)
        {
            instance = new ManagerContainer();
        }
        return instance;
    }

    public Manager findManagerById(int id){
        Manager mObject = null;
        int index = 0;
        boolean found = false;
        while(index < managerContainer.size() && !found)
        {
            mObject = managerContainer.get(index); 
            if(mObject.getManagerId() == id)
            {
                found = true;
            }
            else{
                index++;
            }
        }//end while
        return managerContainer.get(index);

    }
    
    public void addManager(Manager m)
    {
        managerContainer.add(m);
    }
    
    public void deleteManager(Manager m)
    {
        if(managerContainer.contains(m))
            managerContainer.remove(m);
    }
}
